import request from '@/utils/request.js'

const getCateListAPI = () => {
  return request({
    method: 'get',
    url: '/my/cate/list'
  })
}

const addCateAPI = (addForm) => {
  return request({
    method: 'post',
    url: '/my/cate/add',
    data: addForm
  })
}

const getArtDetailAPI = (id) => {
  return request({
    method: 'get',
    url: '/my/cate/info',
    params: {
      id
    }
  })
}

// 定义修改文章的接口
const updateArtAPI = (editForm) => {
  return request({
    method: 'put',
    url: '/my/cate/info',
    data: editForm
  })
}

// 定义删除分类的接口函数
const delCateAPI = (id) => {
  return request({
    method: 'delete',
    url: '/my/cate/del',
    params: {
      id
    }
  })
}

// 发布文章
const pubArticleApi = (formDate) => {
  return request({
    method: 'post',
    url: '/my/article/add',
    data: formDate
  })
}

const getArtListAPI = (q) => {
  return request({
    method: 'get',
    url: '/my/article/list',
    params: q
  })
}

const getArtDetail = (id) => {
  return request({
    method: 'get',
    url: '/my/article/info',
    params: {
      id
    }
  })
}

const delArtAPI = (id) => {
  return request({
    method: 'delete',
    url: '/my/article/info',
    params: {
      id
    }
  })
}

export { getCateListAPI, addCateAPI, getArtDetailAPI, updateArtAPI, delCateAPI, pubArticleApi, getArtListAPI, getArtDetail, delArtAPI }
